class DateUtil{

  formatDate(num: number): string{
    let date = new Date(num)
    let year = date.getFullYear()
    let month = date.getMonth()+1
    let day = date.getDate()
    let m = month < 10 ? '0' + month : month
    let d = day < 10 ? '0' + day : day
    return `${year}-${m}-${d}`
  }

  getMonthDayHourMinute(num: number): string{
    let date = new Date(num)
    let year = date.getFullYear()
    let month = date.getMonth()+1
    let day = date.getDate()
    let hour = date.getHours()
    let minute = date.getMinutes()
    let m = month < 10 ? '0' + month : month
    let d = day < 10 ? '0' + day : day
    let h = hour < 10 ? '0' + hour : hour
    let min = minute < 10 ? '0' + minute : minute
    return `${year}-${m}-${d} ${h}:${min}`
  }

  getYearMonth(){
    let date = new Date()
    let year = date.getFullYear()
    let month = date.getMonth()+1
    let m = month < 10 ? '0' + month : month

    return `${year}年${m}月`
  }
  getDate(){
    let date = new Date()
    let day = date.getDate()
    let d = day < 10 ? '0' + day : day

    return `${d}`
  }

  getCurrentDayOfWeek() {
    const daysOfWeek = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    const currentDate = new Date();
    const dayOfWeekIndex = currentDate.getDay();

    return daysOfWeek[dayOfWeekIndex];
  }

  beginTimeOfDay(date: Date){
    let d = new Date(date.getFullYear(), date.getMonth(), date.getDate())
    return d.getTime()
  }
}

let dateUtil = new DateUtil()

export default dateUtil as DateUtil